package com.itentbase.match.common.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateSplicingUtil {

    /**
     * 将字符串类型的时间和日期拼接后转为时间类型
     *
     * @param dateString
     * @param timeString
     * @return
     */
    public static LocalDateTime getDateSplicing(String dateString, String timeString) {
        String dateStr = dateString +" "+ timeString;
        // 定义日期时间格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        LocalDateTime localDateTime = LocalDateTime.parse(dateStr, formatter);
        return localDateTime;

    }

    /**
     * 将String字符转换为日期格式
     * @param dateString
     * @return
     */
    public static LocalDate getLocalDate(String dateString){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate localDate = LocalDate.parse(dateString, formatter);
        return localDate;
    }
}
